Skip to content

Conversation

jinzcdev
Copy link

@jinzcdev jinzcdev commented May 10, 2025

Issue 1

Description

The XMindMark specification clearly states that subtopics of a Summary Topic can have Boundaries, as mentioned in the documentation:

So you can perform Boundary, Relationship with summary topic and it's sub-topics just like other normal topics:

* topic 1 [S]
* topic 2 [S][1]
[S]: Summary Topic[^1]
    - subtopic 1 [B]
    - subtopic 2 [B]

However, when using this feature in practice, the following error occurs:

mindmark.ts:109  Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'filter')
    at addLine (mindmark.ts:109:10)
    at mindmark.ts:183:60
    at Array.forEach (<anonymous>)
    at createMapByXMindMark (mindmark.ts:183:44)
    at map.ts:25:19
    at new Promise (<anonymous>)
    at renderMapByString (map.ts:24:10)
    at main.ts:60:9

This indicates that the current implementation cannot properly handle boundary markers on Summary Topic subtopics.

Error Screenshot

Error

Changes Made

  1. Fixed the logic in mindmark.ts that handles boundaries for Summary Topic subtopics
  2. Added corresponding unit tests to verify that Summary Topic subtopics can correctly add boundaries

Fixed Result

Fixed Error

Unit Tests

Added unit test case to verify that boundaries can be correctly applied to Summary Topic subtopics:

it('Subtopics with boundaries', () => {
    let map = createMapByXMindMark(`
central topic
* topic 1 [S]
* topic 2 [S]
[S] summary topic
    - subtopic 1 [B]
    - subtopic 2 [B]
    [B] boundary topic
    `)
    // Verification logic...
})

Issue 2

Description

The XMindMark specification allows summary topics to have their own subtopics. However, the current implementation incorrectly adds the subtopics of a summary topic to the last processed regular topic, rather than to the summary topic itself. This causes incorrect structure in the map when attempting to create subtopics under a summary topic:

central topic
- subtopic 1[S]
    - subsubtopic 1
[S] summary topic
    - summarySubtopic 1
    - summarySubtopic 2

With the current implementation, summarySubtopic 1 and summarySubtopic 2 are incorrectly added as children of subtopic 1 instead of under summary topic.

Error Screenshot

Error

Changes Made

  1. Updated the parser logic in mindmark.ts to correctly associate summary topic subtopics with their parent summary topic
  2. Added logic to update the levels array when processing a summary topic, ensuring proper parent-child relationships

The key change was adding code to update the hierarchy levels after processing a summary topic:

// Update levels array, setting summary topic as new parent topic level
let summaryLevel = { 
  parent: topicObject, 
  indent: indent + 4, // Reserve indentation level for subtopics
  boundaries: [], 
  summaries: [] 
}

// Add new level or replace existing level with same indentation
const existingLevelIndex = status.levels.findIndex(l => l.indent === indent + 4)
if (existingLevelIndex >= 0) {
  status.levels[existingLevelIndex] = summaryLevel
} else {
  status.levels.push(summaryLevel)
}

Fixed Result

Fixed Error

Unit Tests

Added unit test case to verify that subtopics are correctly added to summary topics:

it('SubSubtopics', () => {
    let map = createMapByXMindMark(`
central topic
- subtopic 1[S]
    - subsubtopic 1
[S] summary topic
    - summarySubtopic 1
    - summarySubtopic 2
        `)
        
    // Verify ...
})

- add unit tests for summary subtopics with boundaries
@jinzcdev jinzcdev changed the title fix: correct undefined in summary subtopics with boundaries fix(parser): correct undefined in summary subtopics with boundaries May 10, 2025
@jinzcdev jinzcdev changed the title fix(parser): correct undefined in summary subtopics with boundaries fix(parser): correct undefined in summary subtopics with boundaries & summary handling with nested subtopics May 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant